#！/bin/bash
source /etc/profile
if [ -n "$1" ]
then
do_date=$1
else
do_date=`date -d "-1 day" +%F`
fi
sql="
insert overwrite table dim.dim_trade_shops
select shopid, userid, areaid, shopname, shoplevel, status, createtime, modifytime,
    case  when modifytime is not null 
    then substr(modifytime,1,10)
    else substr(createtime,1,10) 
    end as start_dt, 
    '9999-12-31' as end_dt
from ods.ods_trade_shops where dt='2020-07-12';
" 
hive -e "$sql"